package Level02_five;

import java.util.ArrayList;

public class Test {
    private static int count;
    public static void frequency(ArrayList arr, String key) {
        for (Object o : arr) {
            if (o.equals(key)) {
                count++;
            }
        }
        System.out.println("出现"+key+"的次数为："+count);
    }
    public static void main(String[] args) {
        ArrayList<Object> arrayList = new ArrayList<>();
        arrayList.add("a");
        arrayList.add("b");
        arrayList.add("c");
        arrayList.add("c");
        arrayList.add("a");
        arrayList.add("b");
        arrayList.add("b");
        arrayList.add("b");
        arrayList.add("b");
        arrayList.add("a");
        frequency(arrayList, "a");

    }
}
